# import random
#
#
# a = random.randint(1,100)
# n =int(input('请输入数字'))
# if a<n:
#     print('大了')
# elif a>n:
#     print('小了')
# else:
#     print('对了')

# import random
# #
# #
# def guess_number_game():
#     # 1. 系统随机生成一个1-100之间的整数
#     secret_number = random.randint(1, 100)
#     attempts = 0
#
#     print("欢迎来到猜数字游戏！")
#     print("系统已经生成了一个1到100之间的随机数，请开始你的猜测。")
#     i=5000
#
#     while True:
#         try:
#             # 2. 用户从键盘输入猜的数字
#             guess = int(input("\n请输入你猜的数字（1-100）: "))
#             attempts += 1
#
#
#             # 3. 判断用户输入与系统生成的数字
#             if i<500:
#                 print('余额不足')
#             elif guess < secret_number:
#                 i=i-500
#                 print(f"提示：{guess} 小了，请再试一次！")  # a) 提示小了
#                 print(i)
#             elif guess > secret_number:
#                 i=i-500
#                 print(f"提示：{guess} 大了，请再试一次！")  # b) 提示大了
#                 print(i)
#             else:
#                 # c) 猜中数字
#                 i=i+3000
#                 print(f"\n恭喜你猜中了！本轮幸运数字是：{secret_number}")
#                 print(f"你总共尝试了 {attempts} 次")
#                 print(i)
#                 a=int(input('是否继续下一轮游戏,是输入1，否输入2'))
#                 if a == 1 :
#                     continue
#                 else:
#                   break
#
#         except ValueError:
#             print("输入无效！请输入1到100之间的整数。")
#
#
# # 启动游戏
# if __name__ == "__main__":
#     guess_number_game()


# a=1
# while a<10:
#     b=1
#     while b<a:
#         print(b,'*',a,'=',b*a,end='   ')
#         b+=1
#     print()
#     a+=1





# a = 1
# while a <= 9:      # 外层控制行数（1-9）
#     b = 1          # 每行从1开始
#     while b <= a:  # 内层控制列数（不超过当前行数）
#         # 使用格式化输出，对齐结果
#         print(f"{b}×{a}={b*a:2d}", end="  ")
#         b += 1     # 列计数器递增
#     print()        # 换行
#     a += 1         # 行计数器递增





# a=["apple","banana"]
# for x in a:
#      print(x)


# sum=0
# for x in range(101):
#     sum+=x
# print('1+2+3+.....+100=',sum)





# 购物
# import random
#
# money = random.randint(1000,10000)
# jia=0
# goodlist = [
#     {"name":"apple","price":"10"},
#     {"name":"banana","price":"5"},
#     {"name":"watermalen","price":"15"}
# ]
# gcarlist = []
# e=0
# a=input("请输入开始进行抽奖")
# if a=="开始":
#     b=random.randint(1,10)
#     print("恭喜，您的优惠是",b)
# print('展示商品')
# for product in goodlist:
#     print(product)
#     print()
# while True:
#    x = input('请输入商品')
#    if x.lower()=='q':
#        break
#    if x.lower()=='w':
#        c=input("请输入要退的商品")
#        for d in gcarlist:
#            if c.lower()==d["name"].lower():
#                jia-=int(d["price"])/b
#                gcarlist.pop(e)
#                break
#            elif c!=d["name"]:
#                e+=1
#    f=0
#    for g in goodlist:
#      if x.lower() ==g["name"].lower():
#         if money<int(g["price"])/b:
#             print('穷鬼，钱不够！您的余额还剩',money,'请到其他超市购买')
#             f+=1
#         else:
#             gcarlist.append(g)
#             money -= int(g["price"])/b
#             jia+=int(g["price"])/b
#             print('恭喜，购买成功！您的卡余额还有',money)
#             f+=1
#         break
#    if f==0:
#          print('没有这个商品，别瞎搞！')
# if not gcarlist:
#     print("\n🛒 您的购物车是空的，没有购买任何商品")
# print("\n====== 购物小票 ======")
# print('               ','商品','    ' '价格')
# print(gcarlist)
# print('总计',jia)
# print("======================")



# for i in range(1,5):
#     for j in range(1,5):
#         for k in range(1,5):
#             if (i!=k) and(i!=j) and(j!=k):
#                 print(i,j,k)




# i=int(input('请输入利润'))
# if i<=100000:
#     a=i*0.1+i
#     print('总利润为',a)
# elif 100000<i<=200000:
#     a=10000+(i-100000)*0.075
#     print('总利润为', a)
# elif 200000<i<=400000:
#     a=10000+7500+(i-200000)*0.05
#     print('总利润为', a)
# elif 400000<i<=600000:
#     a=10000+7500+10000+(i-400000)*0.03
#     print('总利润为', a)
# elif 600000<i<=1000000:
#     a=33500+(i-600000)*0.015
#     print('总利润为', a)
# elif i>=1000000:
#     a=39500+(i-1000000)*0.01
#     print('总利润为', a)


# list1=[1,2,3,4,5]
# list2=[]
# for i in list1:
#     if 1<=i<=4:
#         list2.append(i)
# print(list2,end="    ")
# list1.append(6)
# list1.remove(3)
# list1[1]=8
# for i in range(0,5):
#     if list1[i]==8:
#         print(i)
# print(list1)
# for g in list1:
#     print(g,end="  ")
# list2=[7,8,9]
# for i in list2:
#     list1.append(i)
#     print(list1)


# my_list = [3, "apple", 9, "banana", 7, "cherry", 2, "date", 5, "elderberry"]
# my_list.append("fig")
# my_list.remove("banana")
# my_list[3]="grape"
# list=[]
# for g in my_list:
#     if type (g) is int:
#         continue
#     elif type(g) is str:
#         list.append(g)
# list.sort()
# a=0
# for i in my_list:
#     if type(i) is int:
#         continue
#     elif type(i) is str:
#         i=list[a]
#         a+=1
#
# print(list)

# print(my_list)





# my_list=[]
# for g in range(1,101):
#     if g%2==0:
#         my_list.append(g)
# a=0
# for i in my_list:
#     my_list[a]=i*i
#     a+=1
# list=[]
# a=0
# for q in my_list:
#     if q<1000:
#         list.append(q)
# my_list=list
# list1=[]
# for w in my_list:
#     list1.insert(0,w)
# my_list=list1
# print(my_list[0:10:1])
# list2=[101,102,103]
# for e in list2:
#     my_list.append(e)
# b=0
# for sumh in my_list:
#     a+=sumh
#     b+=1
# r=a/b
# print(r)
# list3= [i*2 for i in my_list]
# print(list3)
# for index,list in enumerate(my_list):
#     print(index,list)




# print(my_list)


# with open("liu.txt","w") as file:
#     for i in my_list:
#         file.write(f"{i}\n")
#




# person_info = {
#     "name": "Alex",
#     "age": 30,
#     "country": "USA",
#     "language": ["English", "Spanish"],
#     "is_student": False
# }
#
# person_info.update({"age":31})
# person_info.update({"height":175})
# del person_info["is_student"]
# for i in person_info.items():
#     print(i)
# a=0
# for i in person_info.keys():
#     if i=="email":
#         continue
#         a+=1
# if a ==0:
#     person_info.update({"email": "alex@example.com"})
# person_info.update({"language":"english"})
# print(len(person_info["language"]))
# person_info["language"]="french,english"
# for i in range(1,4):
#     key = f'hobby{i}'
#     value=f'hobby{i}'
#     person_info.update({key:value})



# print(person_info["name"])
# print((person_info))
#
# employees = {
#     101: {
#         "name": "Alice",
#         "age": 30,
#         "gender": "Female",
#         "position": "Data Scientist",
#         "team": "Research",
#         "salary_history": [70000, 80000, 90000]
#     },
#     # 更多员工数据...
# }
#
#
#
#
# employees.update({102:{
#          "name": "Alice",
#         "age": 30,
#         "gender": "Female",
#         "position": "Data Scientist",
#         "team": "Research",
#         "salary_history": [70000, 80000, 90000]
# }
# }
# )
# list=[]
# for id,de in employees.items():
#     if de["age"]>25:
#         zd.append({
#             "id":id,
#             "name":de["name"]
#         })
# print(zd)
# for de in employees.values():
#     de.update({"bonus":900})

# del employees[102]
# zd={}
#
#
# for i,d in employees.items():
#      zd.update({i:{
#         "name":d["name"],
#         "position":d["position"]
#     }})
#
# print(zd)
# print(employees)





# s = "Hello, Python world!"
# print(len(s))
# a=0
# for i in s:
#     if i =="o":
#        a+=1
# print(a)
# s=s.upper()
# s=s.lower()

# print(s.find("python"))
# s=s.replace("world","universe")
# if s.startswith("hello"):
#     print("是以hello开头的")
# else:
#     print("不是hello开头")
# if s.endswith("!"):
#     print("是以！结尾的")
# s=s.strip("!")
# s=s[::-1]
# s=s[7:13]
# s=s.lstrip("Hello")
# s1="Hello,"
# s2="World"
# s3=s1+s2
# print(s3)
# s=f"{s}{2021}"
# print(s.find("e"))
# print(s.count(" "))
# s=s.split(",")
# list=[]
# for i in s:
#     list.append(i)
# print(list)
# s=list
# s.sort()
# a=s.isnumeric()
# print(a)
# list = ['Hello,', 'Python', 'World!']
# rs=" ".join((list[0],list[1],list[2]))
# print(rs)
# s=s.lower()
# rw="number :%d"%100
# print(rw)
# a=s.islower()
# print(a)
# list=[1,2,3]
#
# rs="-".join(map(str,list))
# print(rs)
#
# b=0
# for i in s:
#     if i =="o" :
#         print(b)
#         b+=1
#     else:
#         b+=1
# s=s.replace("o","O",1)

# print(s)








# s = "Python is great!"
# a=""
# for i in s:
#    a=i+a
# print(a)
# s=s.replace(" ","_")
# print(s)
# s2 = "A man, a plan, a canal, Panama!"
# s3=''.join(filter(str.isalnum, s2)).lower()
# if s3==s3[::-1]:
#     print("true")
# else:
#     print("false")
# a=s.find("is")
# print(a)

# a=s.find("t")
# list=[i for i in s]
# list.insert(a+1,"_inserted")
# s="".join(map(str,list))
# print(s)

# s=s.replace("great","awesome",1)
# print(s)
# list=[i.upper() for i in s]